Setup


In [1]:
import matplotlib.pyplot as plt
import os
import numpy as np
import pprint

from wind_tunnel import AeroCoefficients, TunnelRecord

import sympy_utils

%load_ext autoreload
%autoreload 2

%matplotlib inline
plt.rcParams['lines.markersize']= 10
plt.rcParams['font.size']= 12

Assumed Constants


In [2]:
const = {'S': 0.35, 'c_bar': 0.3, 'x_ac': 0.1, 'rho': 1.225, 'span': 0.91}

Load Data and Perform Aerodynamic Fitting


In [3]:
tr_mounts = TunnelRecord.load(
    os.path.join('flapping-wing',
                 'camflyer062814mountscont_.txt'), skip=[0])
ac_mounts = AeroCoefficients.from_TunnelRecord(tr_mounts, const['S'], const['c_bar'])

In [4]:
tr = TunnelRecord.load(
    os.path.join('flapping-wing',
                 'FlappingWing1.txt'), skip=[0])
ac = AeroCoefficients.from_TunnelRecord(tr, const['S'], const['c_bar'])
ac = ac.subtract(ac_mounts)
ac.plot()
tr_glide = tr
glide = {'fit': ac.fit(), 'tr': tr, 'ac': ac}
glide['fit']


Out[4]:
{'C_D_0': 0.053674633868212168,
 'C_L_0': 0.099598674209744054,
 'C_L_DM': 0.1353688204500561,
 'C_L_alpha': 1.7610242115963182,
 'C_l_alpha': -2.6366016392535383,
 'C_m_alpha': 0.3197909125923592,
 'C_n_alpha': -9.4357473188441343,
 'k_CD_CL': 0.3345291353136095}

In [5]:
glide_fit = sympy_utils.load_repr(os.path.join('save', 's1_glide_fit.repr'));
glide_fit


Out[5]:
{'C_D_0': 0.05367463386821217,
 'C_L_0': 0.09959867420974405,
 'C_L_DM': 0.1353688204500561,
 'C_L_alpha': 1.7610242115963182,
 'C_l_alpha': -2.6366016392535383,
 'C_m_alpha': 0.3197909125923592,
 'C_n_alpha': -9.435747318844134,
 'k_CD_CL': 0.3345291353136095}

In [6]:
tr = TunnelRecord.load(
    os.path.join('flapping-wing',
                 'FlappingWing_roll_left.txt'))
ac = AeroCoefficients.from_TunnelRecord(tr, const['S'], const['c_bar'])
ac = ac.subtract(ac_mounts)
ac.plot();
roll_left = {'fit': ac.fit(), 'tr': tr, 'ac': ac}
roll_left['fit']


Out[6]:
{'C_D_0': 0.059171369292116964,
 'C_L_0': 0.072752784155467654,
 'C_L_DM': 0.10584876607741232,
 'C_L_alpha': 1.1442807812510465,
 'C_l_alpha': -2.8156386805283415,
 'C_m_alpha': -0.15677738684406622,
 'C_n_alpha': -32.710805256670412,
 'k_CD_CL': 0.56360528328344273}

In [7]:
tr = TunnelRecord.load(
    os.path.join('flapping-wing',
                 'FlappingWing_roll_right.txt'))
ac = AeroCoefficients.from_TunnelRecord(tr, const['S'], const['c_bar'])
ac = ac.subtract(ac_mounts)
ac.plot();
roll_right = {'fit': ac.fit(), 'tr': tr, 'ac': ac}
roll_right['fit']


Out[7]:
{'C_D_0': 0.065426383329440313,
 'C_L_0': 0.030517230428125573,
 'C_L_DM': 0.082337206184180542,
 'C_L_alpha': 1.1023502820706819,
 'C_l_alpha': -2.8226201273510672,
 'C_m_alpha': -0.36664378021987387,
 'C_n_alpha': 17.101366018632444,
 'k_CD_CL': 0.50417555041035167}

In [8]:
tr = TunnelRecord.load(
    os.path.join('flapping-wing',
                 'FlappingWing_wings_up.txt'))
ac = AeroCoefficients.from_TunnelRecord(tr, const['S'], const['c_bar'])
ac = ac.subtract(ac_mounts)
ac.plot();
wings_up = {'fit': ac.fit(), 'tr': tr, 'ac': ac}
wings_up['fit']


Out[8]:
{'C_D_0': 0.078200400730167458,
 'C_L_0': 0.032731661386622889,
 'C_L_DM': 0.035472886299610491,
 'C_L_alpha': 0.89547475485620731,
 'C_l_alpha': -2.8396373513219992,
 'C_m_alpha': 0.404797744790662,
 'C_n_alpha': -12.438358159586546,
 'k_CD_CL': 0.62573133564490435}

In [9]:
tr = TunnelRecord.load(
    os.path.join('flapping-wing',
                 'FlappingWing_wings_down.txt'))
ac = AeroCoefficients.from_TunnelRecord(tr, const['S'], const['c_bar'])
ac = ac.subtract(ac_mounts)
ac.plot();
wings_down = {'fit': ac.fit(), 'tr': tr, 'ac': ac}
wings_down['fit']


Out[9]:
{'C_D_0': 0.063514087354008944,
 'C_L_0': 0.10598117527784996,
 'C_L_DM': 0.17888805184485052,
 'C_L_alpha': 1.5806477175604186,
 'C_l_alpha': -2.5093380119713018,
 'C_m_alpha': 0.49970524357584734,
 'C_n_alpha': -3.5094696966468915,
 'k_CD_CL': 0.41782991271601944}

Save Aerodynamic Coefficients


In [11]:
fits = {
    'glide': glide['fit'],
    'roll_left': roll_left['fit'],
    'roll_right': roll_right['fit'],
    'wings_up': wings_up['fit'],
    'wings_down': wings_down['fit']}

sympy_utils.save_repr(fits, os.path.join('save', 's1_aero_fit.repr'))